package ator;

import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 *  @netbeans.hibernate.facade beanClass=ator.Ator
 */
public class AtorFacade { 
    public void saveAtor(Ator ator) {
        Session session = util.HibernateUtil.currentSession();
        Transaction tx = session.beginTransaction();
        session.save(ator);
        tx.commit();
        util.HibernateUtil.closeSession();
    }
    
    public void insereAtor(String nomeAtor){
        Ator novoAtor = new Ator();
        novoAtor.setNomeAtor(nomeAtor);
        saveAtor(novoAtor);
    }
    public java.util.List findByName() {
        Session session = util.HibernateUtil.currentSession();
        org.hibernate.Query query = session.createQuery(
                " select ator " +
                " from  " +
                " Ator as ator " +
                "  where  " +
                " ator.nomeAtor like `%?%` ");
        
        return query.list();
    }
}
